mir: correctly get screen mm sizes
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Thu, 13 Nov 2014 00:47:56 +0000 (01:47 +0100)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Thu, 13 Nov 2014 00:47:56 +0000 (01:47 +0100)
gdk/mir/gdkmirscreen.c

index dedaa021f0c9178b9cc06cbb8dc1fc704150473d..b182d946a44f7ca37eeacb305efd0cf86914588c 100644 (file)
@@ -94,6 +94,29 @@ get_screen_size (MirDisplayConfiguration *config, gint *width, gint *height)
     }
 }
 
+static void
+get_screen_size_mm (MirDisplayConfiguration *config, gint *width, gint *height)
+{
+  uint32_t i;
+
+  *width = 0;
+  *height = 0;
+
+  if (!config)
+    return;
+
+  for (i = 0; i < config->num_outputs; i++)
+    {
+      MirDisplayOutput *o = &config->outputs[i];
+
+      if (!o->used)
+        continue;
+
+      *width += o->physical_width_mm;
+      *height += o->physical_height_mm;
+    }
+}
+
 static void
 update_display_config (GdkMirScreen *screen)
 {
@@ -194,16 +217,18 @@ static gint
 gdk_mir_screen_get_width_mm (GdkScreen *screen)
 {
   g_printerr ("gdk_mir_screen_get_width_mm\n");
-  // FIXME: A combination of all screens?
-  return get_output (screen, 0)->physical_width_mm;
+  gint width, height;
+  get_screen_size_mm (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
+  return width;
 }
 
 static gint
 gdk_mir_screen_get_height_mm (GdkScreen *screen)
 {
   g_printerr ("gdk_mir_screen_get_height_mm\n");
-  // FIXME: A combination of all screens?
-  return get_output (screen, 0)->physical_height_mm;
+  gint width, height;
+  get_screen_size_mm (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
+  return height;
 }
 
 static gint